//鍔犺浇妯″潡
var layer;
var $;
var element;
var util;
var table;
layui.use(['element','table','layer','util','jquery'], function(){
    layer = layui.layer;
    $ = layui.jquery;
    element = layui.element;
    util = layui.util;
    table = layui.table;
    selCustomerTable('','')
});
function selCustomerTable(name,outsideUser){
    $.ajax({
        url:"/articletype/selCustomerTable",
        dataTypr:"post",
        type:"post",
        data:{"name":name,"outsideUser":outsideUser},
        success:function(data){
            getTable(data);
        }
    })
}
function getTable(data){
    table.render({
        elem: '#test1',
        page: true ,
        data:data,
        width:900,
        even:true,
        limits:[5,7,10],
        limit:5,
        cols:[[
            {type:'radio',fixed:'left'},
            {title:'搴忓彿',align:'center',width:100,templet:function(data){
                    return data.LAY_INDEX;
                }},
            {field: 'name', title: '鍚嶇О',align:'center',width:140},
            {field: 'outsideUser', title: '鑱旂郴浜�',align:'center',width:110},
            {field: 'outsidePhone', title: '鑱旂郴浜虹數璇�',align:'center',width:130},
            {field: 'complaints', title: '鎶曡瘔',align:'center',width:100},
            {field: 'serve', title: '鏈嶅姟',align:'center',width:100},
            {field: 'address', title: '鍦板潃',align:'center',width:160}
        ]]
    });
    //头部时间
    table.on("row(test1)",function(obj){
        $("#customerName").val(obj.data.name);
        $("#customerId").val(obj.data.id);
        $("#outsideUser").val(obj.data.outsideUser);
    })
    //模糊查询
    $("#chaxun").on('click',function(){
        //获取模糊查询的名字
        var name = $("input[name=name]").val();
        var outsideUser = $("input[name=outsideUser]").val();
        selCustomerTable(name,outsideUser);
    })
    //确定
    $("#queding").on('click',function(){
        var customerName = $("#customerName").val();
        var customerId = $("#customerId").val();
        var outsideUser = $("#outsideUser").val();
        parent.$("input[name=customerName]").val(customerName);
        parent.$("input[name=customerId]").val(customerId);
        parent.$("input[name=outsideUser]").val(outsideUser);
        //关闭页面
        var layer=parent.layer;
        layer.close(layer.index);
    })
    //取消
    $("#quxiao").on('click',function(){
        var layer=parent.layer;
        layer.close(layer.index);
    })
}